package com.simple.car.loader.server.entity.vo;

import com.simple.car.loader.server.entity.RunningInfo;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.Objects;

/**
 * 运行时数据视图类
 */
public class RunningInfoVo {

    /**
     * 主键
     */
    private Integer id;

    /**
     * 经度
     */
    private Double lon;

    /**
     * 纬度
     */
    private Double lat;

    /**
     * 高度
     */
    private Double height;

    /**
     * 位置描述
     */
    private String position;

    /**
     * 状态描述
     */
    private String describe;

    /**
     * 危险等级
     */
    private String level;

    /**
     * 车辆速度（它是卫星速度，存在一定误差，只可做参考，不完全可信）
     */
    private Double speed;

    /**
     * 发生时间
     */
    private Date createTime;

    /**
     * 视频路径
     */
    private String filePath;

    /**
     * 状态，0：已记录 1：等待中 2：处理中 3：已完成
     */
    private int statue;

    public RunningInfoVo() {

    }

    public RunningInfoVo(RunningInfo runningInfo) {
        Field[] fields = RunningInfo.class.getDeclaredFields();
        Field[] fieldsVo = getClass().getDeclaredFields();
        for (Field field : fields) {
            String name = field.getName();
            for (Field fieldVo : fieldsVo) {
                if (!Objects.equals(name, fieldVo.getName())) {
                    continue;
                }
                boolean accessible = field.isAccessible();
                field.setAccessible(true);
                try {
                    Object o = field.get(runningInfo);
                    fieldVo.set(this, o);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } finally {
                    field.setAccessible(accessible);
                }
            }
        }
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Double getLon() {
        return lon;
    }

    public void setLon(Double lon) {
        this.lon = lon;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public Double getSpeed() {
        return speed;
    }

    public void setSpeed(Double speed) {
        this.speed = speed;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public int getStatue() {
        return statue;
    }

    public void setStatue(int statue) {
        this.statue = statue;
    }
}
